<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/header.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>主页</title>
<style type="text/css">
	.goods{
		display: inline-block;
		margin: 10px 20px;
		cursor: pointer;
	}
	.img{
		width: 260px;
    	height: 320px;
	}
	.price{
	    font-size: 35px;
   		color: red;
	}
	.num{
		font-size: 12px;
	}
	a{
		margin: 0px 10px;
	}
</style>
</head>
<body>
<div style="text-align: center;">
	<form action="goods/toMainPage">
		<input name="g_name" value="${goods.g_name }"><input type="submit">			<br>
		<c:forEach items="${typeList }" var="item">
			<!-- 我们在jsp中拼接html代码时, 时可以在任意位置使用jsp标签的, jsp表本身是封装的Java代码 -->
			<input type="checkbox" value="${item.id }" 
			<c:forEach var="type_id" items="${goods.typeIds}">
				<c:if test="${item.id==type_id}">checked="checked"</c:if>
			</c:forEach> 
			name="typeIds"> ${item.type_name }
		</c:forEach>
	</form>
</div>

<div id="main" style="text-align: center;">
	<c:forEach items="${goodsList }" var="item">
	
		<div class="goods" onclick="toInfo(${item.id})">	
			<img class="img" alt="图片" src="${item.inco }">
			<div class="price">￥${item.price }</div>
			<div class="g_name">${item.g_name }</div>
			<div class="num">剩余:${item.num }</div>
		</div>
	
	</c:forEach>
	
</div>
<div style="text-align: center;margin: 30px 0px">${paging }</div>
</body>
<script type="text/javascript">
	function toInfo(id){
		//location.href = ; //在当前标签页打开
		window.open("goods/toGoodsInfoPage?id="+id,"_blank"); //指定打开的方式
	}
</script>
</html>